package com.homework.ch01;
class Car implements Cloneable{
    public int num=11;

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
class money implements Cloneable{
    public double money;
    public Car a=new Car();
    @Override
    protected Object clone() throws CloneNotSupportedException {
        money tmp=(money)super.clone();
        tmp.a=(Car)this.a.clone();
        return tmp;
    }
}
public class Person implements Cloneable{
    public String name;
    public int age;
    public money m;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
        this.m=new money();
    }

    @Override
    public String toString() {

        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';

    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        //return super.clone();
        Person temp=(Person) super.clone();
        temp.m=(money)this.m.clone();
        return temp;
    }
}
